from rest_framework import serializers
from .models import Area

class AreaSerializer(serializers.ModelSerializer):

    class Meta:
        model = Area
        fields = ['id','name']

class SubsAreaSeriazlier(serializers.ModelSerializer):

    # area_set = AreaSerializer(many=True,read_only=True)
    subs = AreaSerializer(many=True,read_only=True)

    class Meta:
        model = Area
        fields = ['id','name','subs']

"""
省份
[{'id':xxx,'name':'xxx'}]

市 区县
['id':xxx,'name':'xxx','subs':[{'id':xxx,'name':'xxx'}]]
"""